<template>
  <!-- 财务  财务账单 打款申请 -->
  <div class="app-container jklis" v-loading="loading">
    <el-form :model="queryParams" ref="queryForm" :inline="true" class="zdy-form search-form-new" label-width="100px">
      <el-form-item label="账单状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择账单状态" size="small" clearable>
          <el-option v-for="(dict, key) in commonMaps.billStateMap" :key="key" :label="dict.label" :value="key" />
        </el-select>
      </el-form-item>
      <el-form-item label="订单类型" prop="orderType">
        <el-select v-model="queryParams.orderType" placeholder="请选择订单类型" size="small" clearable>
          <el-option v-for="(dict, key) in commonMaps.tenantBillOrderTypeMap" :key="key" :label="dict" :value="key" />
        </el-select>
      </el-form-item>
      <el-form-item label="账单类型" prop="type">
        <el-select v-model="queryParams.type" placeholder="请选择账单类型" size="small" clearable>
          <el-option v-for="(dict, key) in commonMaps.billTypeMap" :key="key" :label="dict.label" :value="key" />
        </el-select>
      </el-form-item>
      <el-form-item label="交易方名称" prop="jiaoyiName">
        <el-input v-model="queryParams.jiaoyiName" placeholder="请输入交易方名称" clearable size="small" />
      </el-form-item>
      <el-form-item label="日期" prop="">
        <el-date-picker v-model="timer" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item class="btns">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="searchList" class="zdy-btn">搜索</el-button>
        <el-button icon="el-icon-refresh" type="primary" plain size="mini" @click="resetQuery" class="zdy-btn zdy-btn-refresh">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="table_box">
      <el-table :data="tableData.records" border height="calc(100vh - 309px)" style="width: 100%">
        <!-- <el-table-column
          prop=""
          label="归属部门"
          min-width="120"
        ></el-table-column> -->
        <el-table-column prop="id" label="ID" width="55"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>
        <el-table-column prop="orderType" label="订单类型" width="110">
          <template slot-scope="scope">
            <div>
              {{ commonMaps.tenantBillOrderTypeMap[scope.row.orderType] }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="orderNo" label="来源单号" width="200"></el-table-column>
        <!-- <el-table-column
          prop="no"
          label="账单编号"
          min-width="120"
        ></el-table-column> -->
        <el-table-column prop="type" label="账单类型" width="100">
          <template slot-scope="scope">
            <div>
              <el-tag :type="commonMaps.billTypeMap[scope.row.type].type">{{ commonMaps.billTypeMap[scope.row.type].label }}</el-tag>
              
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="amount" label="金额" width="100"></el-table-column>
        <el-table-column prop="jiaoyiName" label="交易方"> </el-table-column>
        <el-table-column prop="operatorName" label="处理人"></el-table-column>
        <el-table-column prop="state" label="状态" width="120">
          <template slot-scope="scope">
            <div>
             <el-tag :type="commonMaps.billStateMap[scope.row.state].type">{{commonMaps.billStateMap[scope.row.state].label}}</el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="img" label="图片附件" width="100">
          <template slot-scope="scope">
            <div class="link" @click="viewImgs(scope.row)">查看附件</div>
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="备注"></el-table-column>
        <el-table-column prop="" label="操作">
          <template slot-scope="scope">
            <el-button v-if="scope.row.state==1" type="text" @click="openDakuan(scope.row)">立即处理</el-button>
            <!-- <el-button type="del" @click="jujueDakuan(scope.row)">拒绝打款</el-button> -->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pages-box">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryParams.pageNum" :page-sizes="[10, 20, 30, 40, 50, 60]" :page-size="queryParams.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="tableData.total"></el-pagination>
    </div>
    <!-- <orderDetailDialog ref="orderDetailDialog"></orderDetailDialog> -->
    <imageDialog ref="imageDialog"></imageDialog>
    <dakuanDialog ref="dakuanDialog"></dakuanDialog>
  </div>
</template>

<script>
// import orderDetailDialog from "../businessCenter/saleOrder/components/orderDetailDialog";
import billListApi from "@/api/financeCenter/billList.js";
import imageDialog from "@/components/imageDialog.vue";
import dakuanDialog from "./dakuanDialog.vue";
import payApi from "@/api/financeCenter/pay.js"
export default {
  name: "bullList",
  components: {
    imageDialog,
    dakuanDialog,
  },
  data() {
    return {
      timer: [],
      // 提号时间，商品ID 游戏类型 区服 实名状态   游戏账号【对应的商品链接】
      tableData: {
        records: [],
        total: 0,
      },
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        operatorTimeStart: "",
        operatorTimeEnd: "",
        state: '',
      },
    };
  },
  created() {
    this.getList();
  },
  activated() {},
  methods: {
    // 获取列表
    getList() {
      // queryParams 请求列表
      this.loading = true;
      if (this.timer && this.timer.length == 2) {
        this.queryParams.operatorTimeStart = this.timer[0] + " 00:00:00";
        this.queryParams.operatorTimeEnd = this.timer[1] + " 23:59:59";
      } else {
        this.queryParams.operatorTimeStart = "";
        this.queryParams.operatorTimeEnd = "";
      }
      billListApi.tenantFinancialList(this.queryParams).then((res) => {
        this.loading = false;
        this.tableData.records = res.rows;
        this.tableData.total = res.total;
      });
    },
    // 搜索
    searchList() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // openDakuan 打开打款弹窗
    openDakuan(row) {
      this.$refs.dakuanDialog.open(row);
    },
    // // 拒绝打款
    // jujueDakuan(row){
    //   this.$confirm(
    //     "确认拒绝该笔订单打款吗？",
    //     "提示",
    //     {
    //       confirmButtonText: "确定",
    //       cancelButtonText: "取消",
    //       type: "warning",
    //     }
    //   )
    //     .then(() => {
    //       payApi.tenantFinancialStatementRefuse({ id: row.id }).then((res) => {
    //         this.$message.success(res.msg);
    //         this.getList();
    //       });
    //     })
    //     .catch(() => {});
    // },

    // 打开查看图片弹窗
    viewImgs(row) {
      if (row.img) {
        let list = row.img.split(",");
        if (list.length) {
          this.$refs.imageDialog.open(list);
        } else {
          this.$alert("暂无图片");
        }
      } else {
        this.$alert("暂无图片");
      }
    },

    // 余额账单
    systemBill() {
      this.timer = [];
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        operatorTimeStart: "",
        operatorTimeEnd: "",
        state: 3,
      };
      this.getList();
    },

    resetQuery() {
      this.timer = [];
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        operatorTimeStart: "",
        operatorTimeEnd: "",
        state: 1,
      };
      this.getList();
    },

    // 每页条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.getList();
    },
    // 页码改变
    handleCurrentChange(val) {
      this.queryParams.pageNum = val;
      this.getList();
    },
    exportOrder() {},
  },
};
</script>
<style lang="scss" scoped>
.link {
  color: blue;
  cursor: pointer;
}
</style>
